import dt from '@dt/dt'
import server from '@/config/server'

function post(path, auth = true, config = true) {
  return server.api().post(path).auth(auth).config(config)
}

function get(path, auth = true, config = true) {
  return server.api().get(path).auth(auth).config(config)
}

const api = {
  export: get('/dt-order/bo/std/detail/year/exportBonusStdDetailYearUser/[bonusId]').tag('downloadCenter'),
  monthList: post('/dt-order/bo/std/detail/year/selectBonusStdDetailYearDetail'),
  submit: get('/dt-order/bo/std/detail/year/submitBonusStdDetailYearUser/[bonusId]'),
  personEdit: post('/dt-order/bo/std/detail/year/updateBonusStdDetailYearUser')
}

function exportInfo(bonusId) {
  return api.export.fetch({
    bonusId
  })
}

function monthList(bonusDetailId, userId) {
  return api.monthList.fetch({
    bonusDetailId,
    userId
  })
}

function personEdit(bonusId, bonusDetailId, adjustAmount, adjustReason) {
  return api.personEdit.fetch({
    bonusId,
    bonusDetailId,
    adjustAmount,
    adjustReason
  })
}

function submit(bonusId) {
  return api.submit.fetch({ bonusId })
}

export default {
  exportInfo,
  monthList,
  submit,
  personEdit
}
